﻿package chapter_03_Homework;

import java.util.Scanner;

public class Work_Bank {
	Scanner sc = new Scanner(System.in);
	double sum =0.0;
	public void Enter(){

		System.out.println("1.存款\t\t2.取款\t\t0.退出");


	}
	public void make(){
		Enter();
		System.out.print("请选择你需要办理的业务：");
		int choose =sc.nextInt();
		switch(choose){
		case 1:
			SaveMoney();
			make();
			return;
		case 2:
			DrawMoney();
			make();
			return;
		case 0:
			System.out.println("谢谢使用！");
		}
	}

	public void SaveMoney(){
		System.out.println("请您输入存款金额：");
		double money = sc.nextDouble();
		if(money<=0){
			System.out.println("您输入的的金额有误！");
			return;
		}
		sum += money;
		System.out.println("存款成功！");
		System.out.println("***当前余额为："+sum+"元***");
	}

	public void DrawMoney(){
		System.out.println("请您输入取款金额：");
		double money = sc.nextDouble();
		if(money<=0||sum<money){
			System.out.println("您输入的的金额有误或者金额不足！");
			return;
		}
		sum -= money;
		System.out.println("取款成功！");
		System.out.println("***当前余额为："+sum+"元***");
	}

	public static void main(String[] args) {
		Work_Bank bn = new Work_Bank();
		bn.make();
	}
}
